package com.cloud.service;

import com.cloud.dao.EmployeeDao;
import com.cloud.model.Employee;
import com.cloud.model.QEmployee;
import com.querydsl.jpa.impl.JPAQueryFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.transaction.Transactional;
import java.util.List;

/**
 * Created by gang on 2019/2/27.
 */
@Service
@Transactional
public class EmployeeService {
    @Resource
    private EmployeeDao employeeDao;
    @Resource
    JPAQueryFactory jpaQueryFactory;


    public List<Employee> getAll() {
        QEmployee Employee = QEmployee.employee;
        List<Employee> employees = jpaQueryFactory
                .selectFrom(Employee)
                .orderBy(Employee.firstName.asc())
                .fetch();
        System.out.println(employees);
        return employeeDao.findAll();
    }
}
